<?php


namespace app\platform\system\service;


use app\common\model\SysAdmin;
use support\exception\BadException;
use support\utils\UserUtil;
use Webman\Http\Request;

class PlatformAuthService
{
    static function checkAndSetRequest(Request $request, $token)
    {
        $user = SysAdmin::where(['token' => $token])->field("id")->find();
        if (!$user) {
            throw new BadException("登录异常", 401);
        }
        UserUtil::setUid(intval($user['id']));
    }
}